
let stream = weex.requireModule('stream');
export default {
    methods: {
        jump(to) {
            if (this.$router) {
                this.$router.push(to)
            }
        },
        isIpx() {
            return weex && (weex.config.env.deviceModel === 'iPhone10,3' || weex.config.env.deviceModel === 'iPhone10,6');
        },
        GET (api, callback) {
            return stream.fetch({
                method: 'post',
                type: 'json',
                url: 'http://1.194.233.171:8081/' + api
                // url: 'http://10.242.69.181:8089/yanxuan/' + api
            }, callback)
        },
        // POST(api, callback) {
        //     stream.fetch({
        //         method: 'POST',
        //         url: "http://1.194.233.171:8081/" + api,
        //         type: 'json',
        //         body:'{"phone":"1236547","password":"123456"}',
        //         headers:{
        //             'Content-Type':'application/json'
        //         },
        //         mode:"cors"
        //     }, function (ret) {
        //         if (!ret.ok) {
        //             callback.postResult = "request failed";
        //             console.log(ret)
        //         } else {
        //             // console.log('get:' + JSON.stringify(ret));
        //             callback.postResult = JSON.stringify(ret.data);
        //             console.log(ret)
        //         }
        //     }, function (response) {
        //         console.log(response);
        //         // console.log('get in progress:' + response.length);
        //         callback.postResult = "bytes received:" + response.length;
        //     });
        // },
        POST(api, callback) {
            stream.fetch({
                method: 'POST',
                url: "http://1.194.233.171:8081/" + api,
                type: 'json',
                body:'{"phone":"1236547","password":"123456"}',
                headers:{
                    'Content-Type':'application/json'
                },
                mode:"cors"
            },callback)
        }


    }
}
